package cn.yunhe.back.service.impl;

import cn.yunhe.entity.TUser;
import cn.yunhe.back.mapper.TUserMapper;
import cn.yunhe.back.service.TUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author 代码生成器(自动生成LF)
 * @since 2019-06-12
 */
@Service("userService")
@Getter
@Setter
public class TTUserServiceImpl implements TUserService {
    @Autowired
    private TUserMapper tUserMapper;

    public Page<TUser> getUserByPage(String pageNum, String pageSize, TUser tUser) {
        Page<TUser> page = new Page<TUser>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        return (Page<TUser>) tUserMapper.selectPage(page, new QueryWrapper<TUser>().like("username", tUser.getUsername()).eq("state","0"));
    }

    @Override
    public int updateById(TUser tUser) {
        return tUserMapper.updateById(tUser);
    }

    @Override
    public int selectCount() {
        return tUserMapper.selectCount(new QueryWrapper<TUser>().eq("state","0"));
    }

}
